//you have to import system.windows.forms package if you aren't using a form app
this.FormClosing -= new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
this.Close();
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true;
}